<!-- TrainMine.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>我的</title>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css">
	</head>
	<style>
	.base_back_icon1 {
	    height: 20px;
	    position: absolute;


	    left: 15px;
	    margin-top: 6px;
	}
	.bottom0{
		position: fixed;
	    bottom: 0px;
	    width: 100%;
	}
	.bottomClasses{
		margin-bottom: 60px;
		overflow: auto;
	}
  </style>
</style>
	<body>
		<div class="trainMine">
			<!--<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%;position: fixed;"></div>
			<div class="base_navigation_bar base_style_color"  >
				<a class="base_left_item" href="#" onclick="backIndex()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
				<span></span>
			</div>-->
			<div class="user_info_div " style="padding-top: 22px;">
			<img class="base_back_icon1" src="../../image/icon_jiantou.png" alt="" onclick="backIndex()"> 
				<img id="usericon" src="../../image/default_user_icon.png" alt="" >
				<div class="user_name_div base_content_font">
					<span id="user_name"></span>
				</div>
				
				<div class="user_tag_div base_tag_font">
					<table>
						<thead>
							<tr>
								<th id="user_school">(暂无)</th>
								<th id="user_specialty">(暂无)</th>
								<th id="user_class" hidden="hidden">(暂无)</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			<div id="study_info_tag" class="user_info_label base_tag_font" >
				<table id="shixinfo">
					<thead>
						<tr>
							<th class="padding10" id="user_sign"><img class="user_tag_icon" src="../../image/icno11.png" alt="">
							<div class="user_tag_text">
								签到 <span id="sign_num">0</span>
								次
							</div></th>
							<th class="padding10" id="user_day" hidden="hidden"><img class="user_tag_icon" src="../../image/icon_ribao.png" alt="">
							<div class="user_tag_text">
								<span id="day_num">0</span>
								次日报
							</div></th>
							<th class="padding10" id="user_report" hidden="hidden"><img class="user_tag_icon" src="../../image/icno22.png" alt="">
							<div class="user_tag_text">
								<span id="weekly_num">0</span>
								次周报
							</div></th>
							<th class="padding10" id="user_month"><img class="user_tag_icon" src="../../image/icno33.png" alt="">
							<div class="user_tag_text">
								<span id="month_num">0</span>
								次月报
							</div></th>
							<!-- <th class="padding10" id="user_post_info"><img class="user_tag_icon" src="../../image/icno44.png" alt="">
							<div class="user_tag_text">
							岗位信息
							</div></th> -->
						</tr>
					</thead>
				</table>
			</div>
			<ul class="mui-table-view bottomClasses">
				<li id="my_qiehuanjituan" class="mui-table-view-cell" >
					<a class="mui-navigate-right base_content_font">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/icon_jituan.png" alt="">
					</div> <span class="base_grey">集团切换</span> </a>
				</li>
				<!--<li id="my_shouke" class="mui-table-view-cell" hidden="hidden">
				<a class="mui-navigate-right base_content_font base_grey">
				<div class="cell_left_img_div">
				<img class="cell_img" src="../../image/icon_shixibaogao.png" alt="">
				</div> <span class="base_grey">我的授课</span> </a>
				</li>
				<li id="look_qiandao" class="mui-table-view-cell" hidden="hidden">
				<a class="mui-navigate-right base_content_font">
				<div class="cell_left_img_div">
				<img class="cell_img" src="../../image/icon_jituan.png" alt="">
				</div> <span class="base_grey">查看签到</span> </a>
				</li>
				<li id="shixi_manage" class="mui-table-view-cell" hidden="hidden">
				<a class="mui-navigate-right base_content_font">
				<div class="cell_left_img_div">
				<img class="cell_img" src="../../image/icon_jituan.png" alt="">
				</div> <span class="base_grey">实习管理</span> </a>
				</li>-->
				<li id="my_tongjifenxi" class="mui-table-view-cell" hidden="hidden">
					<a class="mui-navigate-right base_content_font base_grey">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/icon_tongji.png" alt="">
					</div> <span class="base_grey">统计分析</span> </a>
				</li>
				<li id="my_shezhi" class="mui-table-view-cell">
					<a class="mui-navigate-right base_content_font base_grey">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/icon_shezhi.png" alt="">
					</div> <span class="base_grey">系统设置</span> </a>
				</li>
				<!--<li id="my_zhoubiantongxue" class="mui-table-view-cell">
				<a class="mui-navigate-right base_content_font base_grey">
				<div class="cell_left_img_div">
				<img class="cell_img" src="../../image/icon_chakanzhou.png" alt="">
				</div> <span class="base_grey">周边同学</span> </a>
				</li>-->
				<li id="my_wanshanxinxi" class="mui-table-view-cell">
					<a class="mui-navigate-right base_content_font">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/icon_wanshaxinxi.png" alt="">
					</div> <span class="base_grey">个人信息</span> </a>
				</li>
				<li id="my_shixijilu" class="mui-table-view-cell" >
					<a class="mui-navigate-right base_content_font">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/icon_jilu.png" alt="">
					</div> <span class="base_grey">我的实习记录</span> </a>
				</li>
				<li id="my_about" class="mui-table-view-cell" >
					<a class="mui-navigate-right base_content_font">
					<div class="cell_left_img_div">
						<img class="cell_img" src="../../image/guanyu.png" alt="">
					</div> <span class="base_grey">关于</span> </a>
				</li>
			</ul>
			<ul class="mui-table-view bottom0" >
				<li id="offline_btn" class="mui-table-view-cell base_title_font base_grey">
					退出账号
				</li>
			</ul>
		</div>
		<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title">确定退出登录？</strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
						<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/mui.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js" type="text/javascript"></script>
	<script type="text/javascript">
		apiready = function() {
		if ($api.getStorage('changfengtype') == 1) {  //学习/教学进来的
             $("#shixinfo").hide();
              $("#my_shixijilu").hide();

        }
			setupData();
			customUI();
			loadData();
			setupNotifi();
			//todo添加监听刷新loadData
		}
		function setupNotifi() {
	     
			api.addEventListener({
				name : 'changeUserIconNotifi'
			}, function(ret, err) {
		
				$('#usericon').attr('src',HeadPortraitIsNull($api.getStorage('cfnetppusericon')));
			});
			api.addEventListener({
				name : 'viewappear'
			}, function(ret, err) {
				loadUserNum();
			});
			api.addEventListener({
				name : 'hideOfflineAlertNotifi'
			}, function(ret, err) {
				$('#offlineAlert').hide();
			});
			//添加切换集团通知
			api.addEventListener({
				name : 'changeJidNotifi'
			}, function(ret, err) {
				loadUserNum();
				loadData();
			});
		}

		function loadUserNum() {
			cfnetppPOST(urlUserNum, {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid')
			}, true, function(data, status) {
				if (status == 'success') {
					if (data.status == 1) {
						var jsonData = data.json;
						$('#day_num').text(jsonData.rbnum);
						$('#sign_num').text(jsonData.signnum);
						$('#weekly_num').text(jsonData.weeklynum);
						$('#month_num').text(jsonData.monthnum);
					}
				}
			});
		}

		function loadData() {
			cfnetppPOST(urlApplst, {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid')
			}, true, function(data, status) {
		   
				if (status == 'success') {
					if (data.status == 1 && data.code!=104) {
						var jsonData = data.json;
						setupUserData(jsonData);
					} else {
					    $('#user_name').text($api.getStorage('cfnetppusername'));
					}
				} else {
				}
			});
		}

		function setupUserData(data) {
	
			$('#user_name').text(data.username);
			//			var school = data.userschool;
			//			if (school == null || school == '') {
			//				school = '(暂无)';
			//			}
			//			$('#user_school').text(school);
			//              alert($api.getStorage('cfnetppjxidname'));
			if ($api.getStorage('changfengtype') == '1') {//学习
				$('#user_school').text($api.getStorage('cfnetppjxidname'));
			} else {
				$('#user_school').text($api.getStorage('cfnetppjidname'));
			}
			var specialty = data.credits;
			if (specialty == null || specialty == '') {
				specialty = '(暂无)';
			}
			$('#user_specialty').text("积分："+specialty);
			var classname = data.coursenumber;
			if (classname == null || classname == '') {
				classname = '(暂无)';
			}
			$('#user_class').text("课程："+classname);
			var userprofile = data.userprofile;
		
			if (userprofile != null) {
		      
				$('#usericon').attr('src', HeadPortraitIsNull(userprofile));
				$api.setStorage('cfnetppusericon', userprofile);
			} else {
				$('#usericon').attr('src',  HeadPortraitIsNull($api.getStorage('cfnetppusericon')));
			}
		}

		function customUI() {
			//设置显示日报/周报
			var opentype = $api.getStorage('cfnetppopentype');
			if (opentype == 0) {//周报
				$('#user_day').hide();
				$('#user_report').show();
			} else if (opentype == 1) {//日报
				$('#user_day').show();
				$('#user_report').hide();
			} else if (opentype == 2) {//日报和周报
				$('#user_day').show();
				$('#user_report').show();
			}
			//设置用户类型
			var userType = $api.getStorage('cfnetSelectType');
			if (userType == 2) {
				setupTeacherUI();
			} else {
				setupStudentUI();
			}
		}

		function setupTeacherUI() {
			$('#user_class').hide();
			$('#study_info_tag').hide();
			$('#my_shixibaogao').hide();
			$('#my_tongjifenxi').show();
			$('#look_qiandao').show();
			$('#shixi_manage').show();
			$('#my_shouke').show();
			$('#my_shixijilu').hide();
		}

		function setupStudentUI() {
			$('#user_class').show();
			$('#study_info_tag').show();
			$('#my_shixibaogao').show();
			$('#my_tongjifenxi').hide();
			// $('#my_shezhi').hide();
		}

		//设置数据
		function setupData() {
			$('#user_sign').click(function() {
				pushToWinWithName('Student_dailyCheckWindow', '../TrainReport/Student_dailyCheckWindow');
			});
			$('#user_day').click(function() {
				pushToWinWithName('Student_submitDaliyReportWindow', '../TrainReport/Student_submitDaliyReportWindow');
			});
			$('#user_report').click(function() {
				pushToWinWithName('Student_submitWeeklyReportWindow', '../TrainReport/Student_submitWeeklyReportWindow');
			});
			$('#user_month').click(function() {
				pushToWinWithName('Student_submitMonthReportWindow', '../TrainReport/Student_submitMonthReportWindow');
			});
			$('#user_post_info').click(function() {
				pushToWinWithName('Student_submitInternship', '../TrainReport/Student_submitInternship');
			});
			$('#usericon').click(function() {
				pushToWinWithName('TrainReplacePhoto', 'TrainReplacePhoto');
			});
			$('#my_tongjifenxi').click(function() {
				pushToWinWithName('TrainStatisticalAnalysis', 'TrainStatisticalAnalysis');
			});
			$('#my_shezhi').click(function() {
				pushToWinWithName('MessageSetting', 'MessageSetting');
			});
			$('#my_shixibaogao').click(function() {
				pushToWinWithName('Student_completionReportWindow', '../TrainReport/Student_completionReportWindow');
			});
			$('#my_zhoubiantongxue').click(function() {
				pushToWinWithName('TrainMineAroundStudents', 'TrainMineAroundStudents');
			});
			$('#my_qiehuanjituan').click(function() {
				pushToWinWithName('TrainGroupList', 'TrainGroupList');
			});
			//我的实习记录
			$('#my_shixijilu').click(function() {
				pushToWinWithName('Student_PracticeRecordWindow', 'Student_PracticeRecordWindow');
			});
			$('#my_wanshanxinxi').click(function() {
				pushToWinWithName('TrainSubmitUserInfo', 'TrainSubmitUserInfo');
			});
			$('#look_qiandao').click(function() {
				pushToWinWithName('Teacher_checkSignWindow', '../Manage/Teacher_checkSignWindow');
			});
			$('#shixi_manage').click(function() {
				jumpMange(1);
			});
			$('#my_shouke').click(function() {
				jumpMange(2);
			});
			$('#my_about').click(function() {
				pushToWinWithName('about', 'about');
			});
			$('#offline_btn').click(function() {
				$('#offlineAlert').show();
			});
		}

		//取消
		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#offlineAlert').hide();
			//			stopMsgNotifi();
			$api.setStorage('cfnetppLoginStatus', 0);
			api.toast({
				msg : '退出登录成功',
				duration : 1000,
				location : 'bottom'
			});
				$api.setStorage('cfnetppusericon', "");
			api.sendEvent({
				name : 'offlineCloseWinNotifi'
			});
			// api.rebootApp();
			//			jumpToNextPage();
		}


		//取消消息发送
		function stopMsgNotifi() {
			var ajpush = api.require('ajpush');
			ajpush.stopPush(function(ret) {
				//            if(ret && ret.status){
				// //取消签到通知
				//                api.cancelNotification({
				//                    id: $api.getStorage('signNotifiID')
				//                });
				//                //取消周报通知
				//                api.cancelNotification({
				//                    id: $api.getStorage('weeklyNotifiID')
				//                });
				//                //取消月报通知
				//                api.cancelNotification({
				//                    id: $api.getStorage('monthNotifiID')
				//                });
				//            }
			});
		}

		function jumpMange(type) {
			if (type == 1) {//实习管理
				if (api.pageParam.Indextype == 'manage') {//如果当前是实习管理模块的我的页
					api.sendEvent({
						name : 'jumpMange',
						extra : {
							page : 1
						}
					});
				} else if (api.pageParam.Indextype == 'learn') {//如果当前是教学模块的我的页
					api.openWin({useWKWebView:true,
						name : 'Teacher_Practice_index',
						url : '../../Teacher_Practice_index.html',
						pageParam : {
							jumptype : 1
						}
					});
					api.closeWin({
						name : 'Teacher_leran_indx'
					});
				}
			} else if (type == 2) {//授课
				if (api.pageParam.Indextype == 'learn') {//如果当前是实习管理模块的我的页
					api.sendEvent({
						name : 'jumpStudy',
						extra : {
							page : 0
						}
					});
				} else if (api.pageParam.Indextype == 'manage') {
					api.openWin({useWKWebView:true,
						name : 'Teacher_leran_indx',
						url : '../../Teacher_leran_indx.html',
						pageParam : {
							jumptype : 1
						}
					});
					api.closeWin({
						name : 'Teacher_Practice_index'
					});
				}
			}
		}

		function pushToWinWithName(winname, url) {
			pushToWin(winname, url + '.html', {});
		}

		function pushToWin(winname, winurl, winparam) {
			api.openWin({useWKWebView:true,
				name : winname,
				url : winurl,
				pageParam : winparam,
				vScrollBarEnabled : false,
				hScrollBarEnabled : false,
				allowEdit : true
			});
		}
	</script>
</html>